<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\CourseType
 *
 * @property int $id
 * @property int $course_id 课程id
 * @property int $classify_id 类型id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType whereClassifyId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType whereCourseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseType onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseType whereDeletedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\CourseType withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseType withoutTrashed()
 */
class CourseType extends Model
{
    use SoftDeletes;

    public static function getCourseType($course_id){
        if(empty($course_id))
            return [];

        $classifyArr = [];
        $courseTypes = self::whereCourseId($course_id)->get();
        if(count($courseTypes) > 0){
            foreach ($courseTypes as $courseType) {
                $classifyInfo = Classify::getClassifyInfo($courseType->classify_id);
                array_push($classifyArr,$classifyInfo);
            }
        }

        return $classifyArr;
    }
}
